package com.tech.provider.controller;

import com.tech.entity.SystemResult;
import com.tech.entity.user.User;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Date;

/**
 * 具体业务的服务入口
 */
@RestController
@RequestMapping(value="XXX")
public class XXXController {

    /**
     * 参数为基本类型或者字符串的请求
     * 请求方式 Get
     * @param id
     * @param name
     * @return
     */
    @RequestMapping(value = "/{id}/{name}", method = RequestMethod.GET)
    public SystemResult<User> getUserByParam(@PathVariable("id")  Integer id, @PathVariable("name") String name){
        SystemResult<User> result = new SystemResult<User>();
        User user = new User();
        user.setId(id);
        user.setName(name);
        user.setNow(new Date());
        result.setCode(0);
        result.setMsg("Success");
        result.setT(user);
        return result;
    }

    /**
     * 请求包含多个参数时
     * 请求方式 POST
     * @return
     */
    @PostMapping("/getUser")
    public SystemResult<User> getUser(@RequestBody User user){
        SystemResult<User> result = new SystemResult<User>();
        result.setT(user);
        result.setCode(0);
        result.setMsg("Success");
        return result;
    }
}
